/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.matrimonybeans;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.Stateless;

/**
 *
 * @author ChauAnh
 */
@Stateless
public class checkPay implements checkPayLocal {

    ConnectDB conDB = new ConnectDB();
    Connection conn;

    @Override
    public Boolean checkPayRegistration(String username) {
        try {
            conn = conDB.getConnection();
            String strSql = "SELECT status FROM Registration WHERE username = '" + username + "'";
            PreparedStatement pstmt = conn.prepareCall(strSql);
            ResultSet rs = pstmt.executeQuery();
            while (rs.next()) {
                if (rs.getString("status").equals("true")) {
                    return true;
                }
            }
        } catch (SQLException ex) {
            Logger.getLogger(Login.class.getName()).log(Level.SEVERE, null, ex);
        } finally {
            try {
                conn.close();
            } catch (SQLException e) {
                Logger.getLogger(Login.class.getName()).log(Level.SEVERE, null, e);
            }
        }
        return false;
    }
}
